#include<bits/stdc++.h>
#define int long long
#define N 400005
using namespace std;
int n;
int dep[N],fa[N],siz[N],son[N],top[N];
int idx,dfn[N];
int len,s[N],p[N],w[N];
int t[N][3],vis[N],c[N];
int ans;
vector<int> g[N],h[N],G[N];
const int mod=1e9+7;
void dfs1(int x,int f){
    dep[x]=dep[f]+1;
    siz[x]=1;
    h[dep[x]].push_back(x);
    for(int i:g[x]){
        dfs1(i,x);
        siz[x]+=siz[i];
        if(siz[i]>siz[son[x]]) son[x]=i;
    }
}
void dfs2(int x,int topf){
    top[x]=topf;
    dfn[x]=++idx;
    if(!son[x]) return;
    dfs2(son[x],topf);
    for(int i:g[x]) if(i!=son[x]) dfs2(i,i);
}
int Lca(int x,int y){
    while(top[x]!=top[y]){
        if(dep[top[x]]<dep[top[y]]) swap(x,y);
        x=fa[top[x]];
    }
    if(dep[x]>dep[y]) swap(x,y);
    return x;
}
bool cmp(int x,int y){return dfn[x]<dfn[y];}
void dfs(int x,int f){
    if(vis[x]){t[x][0]=t[x][1]=1;t[x][2]=0;return;}
    t[x][0]=1;t[x][1]=0;t[x][2]=0;
    for(int i:G[x]){
        if(i==f) continue;
        dfs(i,x);
        int a=t[x][0],b=t[x][1],c=t[x][2];
        t[x][0]=(a*t[i][0]%mod+a*t[i][2]%mod)%mod;
        t[x][1]=(a*t[i][1]%mod+b*t[i][0]%mod+b*t[i][2]%mod)%mod;
        t[x][2]=(c*t[i][0]%mod+c*t[i][1]%mod+c*t[i][2]%mod+b*t[i][1]%mod)%mod;
    }
}
signed main(){
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    scanf("%lld",&n);
    n++;
    for(int i=2;i<=n;i++){
        scanf("%lld",&fa[i]);
        fa[i]++;
        g[fa[i]].push_back(i);
    }
    dfs1(1,0);
    dfs2(1,1);
    w[0]=1;
    for(int i=1;i<=n;i++) w[i]=w[i-1]*2%mod;
    for(int i=1;i<=n;i++){
        len=0;
        for(int j:h[i]) s[++len]=j,vis[j]=1;
        s[++len]=1;
        sort(s+1,s+len+1,cmp);
        int l=len;
        for(int j=1;j<l;j++) s[++len]=Lca(s[j],s[j+1]);
        sort(s+1,s+len+1,cmp);
        len=unique(s+1,s+len+1)-s-1;
        for(int j=2;j<=len;j++){
            p[j]=Lca(s[j-1],s[j]);
            G[p[j]].push_back(s[j]);
        }
        dfs(1,0);
        ans=(ans+t[1][1]*w[n-h[i].size()]%mod)%mod;
        for(int j:h[i]) vis[j]=0;
        for(int j=2;j<=len;j++) G[p[j]].clear();
    }
    printf("%lld\n",ans);
    return 0;
}